3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 use MediaWiki\Auth\AuthManager
;
22 use MediaWiki\MediaWikiServices
;
23 use MediaWiki\Preferences\DefaultPreferencesFactory
;
26 * This class has been replaced by the PreferencesFactory service.
28 * @deprecated since 1.31 use the PreferencesFactory service instead.
33 * A shim to maintain backwards-compatibility of this class, basically replicating the
34 * default behaviour of the PreferencesFactory service but not permitting overriding.
35 * @return DefaultPreferencesFactory
37 protected static function getDefaultPreferencesFactory() {
39 $authManager = AuthManager
::singleton();
40 $linkRenderer = MediaWikiServices
::getInstance()->getLinkRenderer();
41 $config = MediaWikiServices
::getInstance()->getMainConfig();
42 $preferencesFactory = new DefaultPreferencesFactory(
43 $config, $wgContLang, $authManager, $linkRenderer
45 return $preferencesFactory;
51 public static function getSaveBlacklist() {
52 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
58 * @param IContextSource $context
61 public static function getPreferences( $user, IContextSource
$context ) {
62 $preferencesFactory = self
::getDefaultPreferencesFactory();
63 return $preferencesFactory->getFormDescriptor( $user, $context );
67 * Loads existing values for a given array of preferences
70 * @param IContextSource $context
71 * @param array &$defaultPreferences Array to load values for
74 public static function loadPreferenceValues( $user, $context, &$defaultPreferences ) {
75 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
79 * Pull option from a user account. Handles stuff like array-type preferences.
84 * @return array|string
86 public static function getOptionFromUser( $name, $info, $user ) {
87 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
92 * @param IContextSource $context
93 * @param array &$defaultPreferences
96 public static function profilePreferences(
97 $user, IContextSource
$context, &$defaultPreferences
99 wfDeprecated( __METHOD__
, '1.31' );
100 $defaultPreferences = self
::getPreferences( $user, $context );
105 * @param IContextSource $context
106 * @param array &$defaultPreferences
109 public static function skinPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
110 wfDeprecated( __METHOD__
, '1.31' );
111 $defaultPreferences = self
::getPreferences( $user, $context );
116 * @param IContextSource $context
117 * @param array &$defaultPreferences
119 public static function filesPreferences(
120 $user, IContextSource
$context, &$defaultPreferences
122 wfDeprecated( __METHOD__
, '1.31' );
123 $defaultPreferences = self
::getPreferences( $user, $context );
128 * @param IContextSource $context
129 * @param array &$defaultPreferences
132 public static function datetimePreferences(
133 $user, IContextSource
$context, &$defaultPreferences
135 wfDeprecated( __METHOD__
, '1.31' );
136 $defaultPreferences = self
::getPreferences( $user, $context );
141 * @param IContextSource $context
142 * @param array &$defaultPreferences
144 public static function renderingPreferences(
145 $user, IContextSource
$context, &$defaultPreferences
147 wfDeprecated( __METHOD__
, '1.31' );
148 $defaultPreferences = self
::getPreferences( $user, $context );
153 * @param IContextSource $context
154 * @param array &$defaultPreferences
156 public static function editingPreferences(
157 $user, IContextSource
$context, &$defaultPreferences
159 wfDeprecated( __METHOD__
, '1.31' );
160 $defaultPreferences = self
::getPreferences( $user, $context );
165 * @param IContextSource $context
166 * @param array &$defaultPreferences
168 public static function rcPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
169 wfDeprecated( __METHOD__
, '1.31' );
170 $defaultPreferences = self
::getPreferences( $user, $context );
175 * @param IContextSource $context
176 * @param array &$defaultPreferences
178 public static function watchlistPreferences(
179 $user, IContextSource
$context, &$defaultPreferences
181 wfDeprecated( __METHOD__
, '1.31' );
182 $defaultPreferences = self
::getPreferences( $user, $context );
187 * @param IContextSource $context
188 * @param array &$defaultPreferences
190 public static function searchPreferences(
191 $user, IContextSource
$context, &$defaultPreferences
193 wfDeprecated( __METHOD__
, '1.31' );
194 $defaultPreferences = self
::getPreferences( $user, $context );
198 * Dummy, kept for backwards-compatibility.
200 * @param IContextSource $context
201 * @param array &$defaultPreferences
203 public static function miscPreferences( $user, IContextSource
$context, &$defaultPreferences ) {
207 * @param User $user The User object
208 * @param IContextSource $context
209 * @return array Text/links to display as key; $skinkey as value
211 public static function generateSkinOptions( $user, IContextSource
$context ) {
212 wfDeprecated( __METHOD__
, '1.31' );
213 return self
::getPreferences( $user, $context );
217 * @param IContextSource $context
220 static function getDateOptions( IContextSource
$context ) {
221 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
225 * @param IContextSource $context
228 public static function getImageSizes( IContextSource
$context ) {
229 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
233 * @param IContextSource $context
236 public static function getThumbSizes( IContextSource
$context ) {
237 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
241 * @param string $signature
242 * @param array $alldata
243 * @param HTMLForm $form
244 * @return bool|string
246 public static function validateSignature( $signature, $alldata, $form ) {
247 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
251 * @param string $signature
252 * @param array $alldata
253 * @param HTMLForm $form
256 public static function cleanSignature( $signature, $alldata, $form ) {
257 throw new Exception( __METHOD__
. '() is deprecated and does nothing now' );
262 * @param IContextSource $context
263 * @param string $formClass
264 * @param array $remove Array of items to remove
265 * @return PreferencesForm|HTMLForm
267 public static function getFormObject(
269 IContextSource
$context,
270 $formClass = 'PreferencesForm',
273 $preferencesFactory = self
::getDefaultPreferencesFactory();
274 return $preferencesFactory->getForm( $user, $context, $formClass, $remove );
278 * @param IContextSource $context
281 public static function getTimezoneOptions( IContextSource
$context ) {
282 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
286 * @param string $value
287 * @param array $alldata
290 public static function filterIntval( $value, $alldata ) {
291 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
296 * @param array $alldata
299 public static function filterTimezoneInput( $tz, $alldata ) {
300 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );
304 * Handle the form submission if everything validated properly
306 * @param array $formData
307 * @param PreferencesForm $form
308 * @return bool|Status|string
310 public static function tryFormSubmit( $formData, $form ) {
311 $preferencesFactory = self
::getDefaultPreferencesFactory();
312 return $preferencesFactory->legacySaveFormData( $formData, $form );
316 * @param array $formData
317 * @param PreferencesForm $form
319 public static function tryUISubmit( $formData, $form ) {
320 $preferencesFactory = self
::getDefaultPreferencesFactory();
321 return $preferencesFactory->legacySubmitForm( $formData, $form );
325 * Get a list of all time zones
326 * @param Language $language Language used for the localized names
327 * @return array A list of all time zones. The system name of the time zone is used as key and
328 * the value is an array which contains localized name, the timecorrection value used for
329 * preferences and the region
332 public static function getTimeZoneList( Language
$language ) {
333 throw new Exception( __METHOD__
. '() is deprecated and does nothing' );